<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Jquery Ajax Test</title>
    <script src="/static/jquery-3.4.1.js" type="text/javascript">
    </script>
<script>
$(document).ready(function(){
   $(".btn1").click(function(){
      $.get("/mystring",function(data, status){
         alert("数据: " + data + "\n状态: " + status);
      });
   });

    $(".btn2").click(function(){
      $.get("/mydict",function(data, status){
         alert("name: " + data.name + " age:" + data.age);
      });
   });

    $(".btn3").click(function(){
      $.get("/mylist",function(data, status){
         alert("name: " + data[0]+ " age:" + data[1]);
      });
   });

    $(".btn4").click(function(){
      $.ajax({url:"/mystring", data:{"mydata": "test"},success:function(data){
         alert(data);
      }});
   });

       $(".btn6_2").click(function(){
      $.ajax({url:"/dataFromAjax", data:{"mydata": "test data"},success:function(data){
         alert(data);
      }});
   });

    $(".btn5").click(function(){
      $.ajax({url:"/mydict", success:function(data){
         alert("name: " + data.name + " age:" + data.age);
      }});
   });

    $(".btn6").click(function(){
      $.ajax({url:"/mylist", success:function(data){
         alert("name: " + data[0] + " age:" + data[1]);
      }});
   });

   $(".btn7").click(function(){
        $("p").load("../static/test.txt");
   });
   $(".btn10").click(function(){
        $("p").load("/mystring");
   });

    $(".btn8").click(function(){
        $.getJSON("/mydict",function(data){
            $.each(data, function(i, field){
                $("div").append(field + " ");
            });
        });
    });

    $(".btn9").click(function(){
        $.post("/mydict", function(data, status){
         alert("name: " + data.name + " age:" + data.age);
    });
});
});
</script>

</head>
<body>
    <h1>Ajax Test</h1>
    <button class="btn1">get string</button>
    <button class="btn2">get dict</button>
    <button class="btn3">get list</button> <br/><br/>
    <button class="btn4">ajax string</button>
    <button class="btn5">ajax dict</button>
    <button class="btn6">ajax list</button>
    <button class="btn6_2">ajax sentDataToFlask</button><br/><br/>
    <p>load:</p>
    <button class="btn7">load  from file</button>
    <button class="btn10">load</button><br/><br/>
    <div>getJson: </div><br/>
    <button class="btn8">getJson</button><br/><br/>
        <button class="btn9">post</button>
</body>
<a href="www.beian.miit.gov.cn">备案号:豫ICP备19032695号-1</a>
</html>